package tomsung.cloud.agdc.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tomsung.cloud.agdc.bean.Humidity;
import tomsung.cloud.agdc.dao.HumidityMapper;

@Service("HumidityService")
public class HumidityService {

	@Autowired
	HumidityMapper humidityMapper;
	
	public int createHumidityData(Humidity record)
	{
		return humidityMapper.insertSelective(record);
	}
	
	public int deleteHumidityData(Integer groupid)
	{
		return humidityMapper.deleteByPrimaryKey(groupid);
	}
	
	public Humidity selectHumidityData(Integer groupid)
	{
		return humidityMapper.selectByPrimaryKey(groupid);
	}
	
	public int updateHumidityData(Humidity record)
	{
		return humidityMapper.updateByPrimaryKey(record);
	}
	
	public List<Humidity> getHumidityDataBySystemId(List<Long> systemIds, Date beginTime, Date endTime, int devType)
	{
		List<Humidity> humiditys = new ArrayList<Humidity>();
		for (Long id : systemIds)
		{
			List<Humidity> hs = humidityMapper.getHumidityDataBySystemId(id, beginTime, endTime, devType);
			if (hs != null && hs.size() > 0)
			{
				humiditys.addAll(hs);
			}
		}
		return humiditys;
	}
}
